#ifndef FUNCTOR_HH_
# define FUNCTOR_HH_

# include <cassert>
# include <boost/shared_ptr.hpp>

# include <tools/list.hh>

# include "../physic/object.hh"

class Server;
class Client;

class Functor
{
public:
  Functor ();

  virtual void operator() (List<Object*>*)
  {
    assert (false);
  }

  virtual void operator() (unsigned char*)
  {
    assert (false);
  }
};

class DisplayFunctor : public Functor
{
public:
  DisplayFunctor ();
  ~DisplayFunctor ();

  void operator() (List<Object*>* list);
};

class PhysicFunctor : public Functor
{
public:
  PhysicFunctor ();
  ~PhysicFunctor ();

  void operator() (List<Object*>* list);
  void operator() (std::list<Object*>& list);
  std::list<Object*>* intersect_list () const { return intersect_list_; }

  Object* object_get ();
  void object_set (Object* obj);

protected:
  Object* object_;
  std::list<Object*>* intersect_list_;
};

class MapFunctor : public Functor
{
public:
  MapFunctor (Client* client);
  ~MapFunctor ();

  void operator() (unsigned char* str);
  void operator() ();
protected:
  Client* client_;
};

class GetObjectFunctor : public Functor
{
public:
  GetObjectFunctor (Server* s, int clientid);
  ~GetObjectFunctor ();

  void operator() (List<Object*>* list);
protected:
  boost::shared_ptr<Client> client_;

};

#endif /// !FUNCTOR_HH_
